Skip to content

Completed Graph1#783

Open
dharaneesk wants to merge 1 commit intosuper30admin:masterfrom
dharaneesk:master
Open

Completed Graph1#783
dharaneesk wants to merge 1 commit intosuper30admin:masterfrom
dharaneesk:master

Conversation

@dharaneesk
Copy link

No description provided.

@super30admin
Copy link
Owner

Your solution for the town judge problem is excellent. It correctly implements the required logic with optimal time and space complexity. The code is clean and well-commented. However, note that the problem you solved in TownJudge.java is different from TheMaze.java. Make sure to submit the correct file for the correct problem. Also, in the TownJudge solution, you might consider adding a check for n=1 (if n==1, then the judge is person 1) but your code already handles that because for n=1, the indegrees array will have size 2, and you check from index 1 to n. Since there are no trust relationships, indegrees[1] will be 0, which is not n-1 (which is 0) so it would return 1? Wait, let me check: for n=1, we need to return 1. But in your code, if there are no trust relationships, the indegrees array is initialized to zeros. Then you iterate from i=1 to n (which is 1). indegrees[1] is 0, but n-1 is 0. So it returns 1. So it is correct. So no change is needed.

One minor point: in the for-loop condition, you have i<indegrees.length which is correct since indegrees.length is n+1, so it goes from 1 to n. But you could also write i<=n for clarity.

Overall, great job!

@super30admin
Copy link
Owner

Your solution for "Find the Town Judge" is excellent. It correctly implements the indegree counting approach, and the time and space complexities are optimal. The code is clean and well-commented.

One minor note: in the for-loop condition for iterating over the indegrees array, you have i<indegrees.length. Since indegrees has length n+1, this will iterate from index 1 to n, which is correct. However, you could also write i<=n for clarity, but it is not necessary.

Also, please ensure that you only submit the relevant code for the problem you are solving. The inclusion of TheMaze.java in this context is unnecessary and might be confusing.

Overall, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants